import Vue from 'vue'
import store from '@/store'

const permissionInclude = (value, buttons) => {
    let message = false
    for (let [key, data] of Object.entries(buttons)) {
        // debugger
        if (key in value) {
            message = data.some(item => item.id === value[key])
            break
        }
    }
    return message
}
/**
 * 按钮权限，类似于v-if
 * */
Vue.directive('permission', {
    bind(el, binding, vnode) {
        const buttons = store.state.permission.buttons
        // 打开进行验证
        // if (!permissionInclude(binding.value, buttons)) {
        //     Vue.nextTick(() => el.parentNode.removeChild(el))
        // }
    }
})
